Ext.define('AmpleHarvest.objects.forms.geSearch',
{
	extend				: 'Ext.form.Panel',
	alias           	: 'widget.ampleharvest-objects-forms-gesearch',
	source_name			: 'GROUNDEFFECT',
	stateful			: false,
	height				: 600,
	requires			:
	[
			'Ext.form.field.Number', 
			'Ext.form.field.Text',
			'Ext.form.FieldSet', 
			'Ext.form.field.Date',
			'AmpleHarvest.addOns.keyboard.cPlugin',
			'AmpleHarvest.addOns.keyboard.layout.Cyrillic_RU',
			'AmpleHarvest.elements.combobox.cFacet'
	],

	statics				:
	{
		C_STR_FIELD_COST		: "value.cost",
		C_STR_FIELD_CUSTOMER	: "customer",
		C_STR_FIELD_ORDERMETHOD	: "order_method",
		C_STR_FIELD_PUBLISHDATE	: "publish_date",
		C_STR_FIELD_HARVESTDATE	: "harvest_date",
		C_STR_FIELD_INDEXDATE	: "index_date",
		C_STR_FIELD_SOURCE		: "source",
		C_STR_FIELD_TAXID		: "tax_payer_id",
		C_STR_DATATYPE_DATE  	: "date",
		C_STR_DATATYPE_VALUE 	: "value",
		C_STR_DATATYPE_FACET	: "facet"
	},
	
	initComponent			: function()
	{
//		var this.up('ampleharvest-views-search-main').m_obj_preview.store = Ext.create('AmpleHarvest.DATA.Store.geSolr',
//    			{
//			AHcaller	: this
//	}),
//  columns: [
//       {  header      : 'Title', dataIndex   : 'title', flex: 1.5, sortable : true,
//          renderer: function(value, metaData, record) { return "<b>"+value+"</b>" } },
//          
//       {  header      : 'Source',    dataIndex   : 'source', width: 50, sortable : true},
//       {  header      : 'Classification',    dataIndex   : 'classification', width: 100, sortable : true},
//       {  header      : 'Publish Date',    dataIndex   : 'publishDate', width: 125, sortable : true,
//          renderer: function(value, metaData, record) { return value } },
//       {  header      : 'Language',    dataIndex   : 'language',width: 100, sortable : true},
//       {  header      : 'Summary',    dataIndex   : 'summary', flex:1, sortable : false}
//  ],
		
//		this.m_obj_VKeyboard = Ext.create("AmpleHarvest.addOns.keyboard.cPlugin");
		
		this.PublishDateBox = Ext.create("Ext.form.FieldSet",
				{
					title		: "Publish Date",
					collapsible	: true,
					collapsed	: true,
					labelWidth	: 70,
					boxMinWidth	: 275,
					stateId		: 'publish_date',
					stateful	: false

				});

		this.PublishDateBox.add(Ext.create("Ext.form.field.Date",
		{
			fieldLabel	: "Start Date",
			format		: 'Y-m-d H:i:s',
			dataType	: this.self.C_STR_DATATYPE_DATE,
			anchor		: "100%",
			dateTrigger	: 'start',
			name		: this.self.C_STR_FIELD_PUBLISHDATE + "_start",
			searchTerm	: this.self.C_STR_FIELD_PUBLISHDATE,
			allowBlank	: true
		}
		));

		this.PublishDateBox.add(Ext.create("Ext.form.field.Date",
		{
			fieldLabel	: "End Date",
			format		: 'Y-m-d H:i:s',
			dataType	: this.self.C_STR_DATATYPE_DATE,
			anchor		: "100%",
			dateTrigger	: 'end',
			name		: this.self.C_STR_FIELD_PUBLISHDATE + "_end",
			searchTerm	: this.self.C_STR_FIELD_PUBLISHDATE,
			allowBlank	: true
		}
		));

		this.HarvestDateBox = Ext.create("Ext.form.FieldSet",
				{
					title		: "Harvest Date",
					collapsible	: true,
					collapsed	: true,
					labelWidth	: 70,
					boxMinWidth	: 275,
					stateId		: 'harvest_date',
					stateful	: false
				});

		this.HarvestDateBox.add(Ext.create("Ext.form.field.Date",
		{
			fieldLabel	: "Start Date",
			format		: 'Y-m-d H:i:s',
			dataType	: this.self.C_STR_DATATYPE_DATE,
			anchor		: "100%",
			name		: this.self.C_STR_FIELD_HARVESTDATE + "_start",
			searchTerm	: this.self.C_STR_FIELD_HARVESTDATE,
			allowBlank	: true
		}
		));

		this.HarvestDateBox.add(Ext.create("Ext.form.field.Date",
		{
			fieldLabel	: "End Date",
			format		: 'Y-m-d H:i:s',
			dataType	: this.self.C_STR_DATATYPE_DATE,
			anchor		: "100%",
			name		: this.self.C_STR_FIELD_HARVESTDATE + "_end",
			searchTerm	: this.self.C_STR_FIELD_HARVESTDATE,
			allowBlank	: true
		}
		));

		this.IndexDateBox = Ext.create("Ext.form.FieldSet",
				{
					title		: "Index Date",
					collapsible	: true,
					collapsed	: true,
					labelWidth	: 70,
					boxMinWidth	: 275,
					stateId		: 'index_date',
					stateful	: false
				});

		this.IndexDateBox.add(Ext.create("Ext.form.field.Date",
		{
			fieldLabel	: "Start Date",
			format		: 'Y-m-d H:i:s',
			dataType	: this.self.C_STR_DATATYPE_DATE,
			anchor		: "100%",
			name		: this.self.C_STR_FIELD_INDEXDATE + "_start",
			searchTerm	: this.self.C_STR_FIELD_INDEXDATE,
			allowBlank	: true
		}
		));

		this.IndexDateBox.add(Ext.create("Ext.form.field.Date",
		{
			fieldLabel	: "End Date",
			format		: 'Y-m-d H:i:s',
			dataType	: this.self.C_STR_DATATYPE_DATE,
			anchor		: "100%",
			name		: this.self.C_STR_FIELD_INDEXDATE + "_end",
			searchTerm	: this.self.C_STR_FIELD_INDEXDATE,
			allowBlank	: true
		}
		));

		this.CostBox = Ext.create("Ext.form.FieldSet",
				{
					title		: "Cost",
					collapsible	: true,
					collapsed	: true,
					labelWidth	: 70,
					boxMinWidth	: 275,
					stateId		: 'cost',
					stateful	: false
				});

		this.CostBox.add(Ext.create("Ext.form.field.Number",
		{
			fieldLabel	: "Minimum",
			dataType	: this.self.C_STR_DATATYPE_VALUE,
			anchor		: "100%",
			name		: this.self.C_STR_FIELD_COST + "_start",
			searchTerm	: this.self.C_STR_FIELD_COST,
			allowBlank	: true
		}
		));

		this.CostBox.add(Ext.create("Ext.form.field.Number",
		{
			fieldLabel	: "Maximum",
			dataType	: this.self.C_STR_DATATYPE_VALUE,
			anchor		: "100%",
			name		: this.self.C_STR_FIELD_COST + "_end",
			searchTerm	: this.self.C_STR_FIELD_COST,
			allowBlank	: true
		}
		));

		this.m_obj_VKeyboard = Ext.create("AmpleHarvest.addOns.keyboard.cPlugin");
//		console.log(this.m_obj_VKeyboard);
//		var temp_obj = Ext.create("AmpleHarvest.util.cPropertiesDropDown",
//				{
//					fieldLabel	: "Source",
//					name		: 'source',
//					targetPath	: this.str_solr_base,
//					valueField	: 'facet', // TODO: check if needed on all of these dropdowns
//					searchTerm	: this.self.C_STR_FIELD_SOURCE,
//					dataType	: this.self.C_STR_DATATYPE_FACET,
//					anchor		: '92%',
//					emptyText	: 'Enter Source',
//					keyboardConfig	:
//					{
//						languageSelection	: true,
//						language			: AmpleHarvest.addOns.keyboard.layout.Cyrillic_RU.C_STR_NAME,
//						showIcon			: true
//					},
//					plugins			:
//					[
//						this.m_obj_VKeyboard
//					]
//				}
//			);
//		
//		console.log(temp_obj);
		
// TODO: Add this back in when ReadStatus flag is part of the data
//		this.ReadStatus = Ext.create('Ext.form.ComboBox',
//				{
//					fieldLabel		: 'Read',
//					store			: Ext.create('Ext.data.Store',
//							{
//								fields	:
//								[
//										'label', 'term'
//								],
//								data	:
//								[
//										{
//											"label"	: "Read",
//											"term"	: "read"
//										},
//										{
//											"label"	: "Unread",
//											"term"	: "unread"
//										},
//										{
//											"label"	: "All",
//											"term"	: ""
//										}
//								// ...
//								]
//							}),
//					anchor			: "100%",
//					name			: "read",
//					value			: "",
//					queryMode		: 'local',
//					displayField	: 'label',
//					valueField		: 'term'
//				});

		this.items =
		[
				Ext.create("Ext.form.field.TextArea",
				{
					fieldLabel		: "General",
					itemId			: 'f_general',
					id				: 'ampleHarvest-objects-forms-textarea'+this.str_unique_id,
					name			: "general",
					hiddenName		: "general",
					inputType		: "textfield",
					allowBlank		: true,
					// value : g_arr_Requests["general"],
					anchor			: "92%",
					keyboardConfig	:
					{
						languageSelection	: true,
						language			: AmpleHarvest.addOns.keyboard.layout.Cyrillic_RU.C_STR_NAME,
						showIcon			: true,
						AHcaller			: this
					},
					plugins			:
					[
					 	this.m_obj_VKeyboard
					]	
				}
				),
				
				Ext.create("AmpleHarvest.util.cPropertiesDropDown",
					{
						fieldLabel	: "Customer",
						name		: 'customer',
						inputType	: "solrfacet",
						targetPath	: this.str_solr_base,
						valueField	: 'facet',
						searchTerm	: this.self.C_STR_FIELD_CUSTOMER,
						dataType	: this.self.C_STR_DATATYPE_FACET,
						anchor		: '92%',
						emptyText	: 'Select Customer',
					}
				), 

				Ext.create("AmpleHarvest.util.cPropertiesDropDown",
					{
						fieldLabel	: "Source",
						name		: 'source',
						targetPath	: this.str_solr_base,
						valueField	: 'facet', // TODO: check if needed on all of these dropdowns
						searchTerm	: this.self.C_STR_FIELD_SOURCE,
						dataType	: this.self.C_STR_DATATYPE_FACET,
						anchor		: '92%',
						emptyText	: 'Enter Source'
//							,
//						keyboardConfig	:
//						{
//							languageSelection	: true,
//							language			: AmpleHarvest.addOns.keyboard.layout.Cyrillic_RU.C_STR_NAME,
//							showIcon			: true
//						},
//						plugins			:
//						[
//							this.m_obj_VKeyboard
//						]
					}
				), 
				Ext.create("AmpleHarvest.util.cPropertiesDropDown",
					{
						fieldLabel	: "Tax Payer ID",
						name		: 'taxpayerid',
						targetPath	: this.str_solr_base,
						valueField	: 'facet',
						searchTerm	: this.self.C_STR_FIELD_TAXID,
						dataType	: this.self.C_STR_DATATYPE_FACET,
						anchor		: '92%',
						emptyText	: 'Enter Tax Payer ID'
					}
				), 
				Ext.create("AmpleHarvest.util.cPropertiesDropDown",
					{
						fieldLabel	: "Order Method",
						name		: 'ordermethod',
						targetPath	: this.str_solr_base,
						valueField	: 'facet',
						searchTerm	: this.self.C_STR_FIELD_ORDERMETHOD,
						dataType	: this.self.C_STR_DATATYPE_FACET,
						anchor		: '92%',
						emptyText	: 'Enter Order Method'
					}
				), 
				/*this.ReadStatus,*/ this.CostBox, this.PublishDateBox,
				this.HarvestDateBox, this.IndexDateBox
		];
		
		this.callParent();
	}
}

);